package com.wt.struggle.goodbye.user.activity

import android.os.Bundle
import android.os.Message
import android.text.Editable
import android.text.TextWatcher
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.Config
import com.wt.struggle.goodbye.base.ProActivity
import com.wt.struggle.goodbye.base.Send
import com.wt.struggle.goodbye.info.NetInfo
import kotlinx.android.synthetic.main.appeal_layout.*
import kotlinx.android.synthetic.main.head.*

/**
 * 申诉封号
 */
class AppealActivity : ProActivity() {

    override fun handler(what: Int, arg1: Int, netInfo: NetInfo) {
        when (what) {
            Send.GET_USER_INFO -> {

                removeLoadDialog()
                if (netInfo.code == Config.SUCCESS) {
                    finish()
                }

            }
        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.appeal_layout)
        tvTitle.text = "申诉封号"

        imageBack.setOnClickListener {
            finish()
        }

        etContentText.addTextChangedListener(object : TextWatcher {
            override fun afterTextChanged(p0: Editable?) {

            }

            override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

            }

            override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
                val content = etContentText.text.toString()
                tvTextTi.text = "${content.length}/200字"
            }
        })


        buttonTi.setOnClickListener {
            val content = etContentText.text.toString()
            if (content != "") {
                send!!.unConferred(content, handler)
                showLoadDialog()
            } else {
                showToastShort("请写点什么吧！")
            }
        }


    }
}